package com.sloth.bear.dto.base;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.sloth.bear.constant.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Response<T> {
    
    private Integer code;
    private String message;
    private T data;
    
    public static <T> Response<T> success() {
        return new Response<>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), null);
    }
    
    public static <T> Response<T> success(T data) {
        return new Response<>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data);
    }
    
    public static <T> Response<T> error(Integer code, String message) {
        return new Response<>(code, message, null);
    }
    
    
}